
Namespace Math
  ''' <summary>
  ''' Math helper class.
  ''' </summary>
  ''' <remarks></remarks>
  Public NotInheritable Class MathHelper

    ''' <summary>
    ''' Converts decimal and returns places after decimal point.
    ''' </summary>
    ''' <param name="inputValue">Decimail value to convert.</param>
    ''' <param name="placesAfter">Places after the decimail to return.</param>
    ''' <returns>Converted decimal.</returns>
    ''' <remarks></remarks>
    Shared Function ConvertDecimal(ByVal inputValue As Decimal, ByVal placesAfter As Int32) As Decimal
      Dim convertedValue As System.Text.StringBuilder = New System.Text.StringBuilder()
      Dim tempValue As String = Convert.ToString(inputValue, CultureInfo.CurrentCulture)
      Dim tempSplit() As String = tempValue.Split(Convert.ToChar(".", CultureInfo.CurrentCulture))

      If (tempSplit.GetLowerBound(0) = 0) Then
        convertedValue.Append(tempSplit(0))
      End If

      If (tempSplit.GetUpperBound(0) = 1) Then
        convertedValue.Append(".")
        convertedValue.Append(tempSplit(1).Substring(0, placesAfter))
      End If

      Return Convert.ToDecimal(convertedValue.ToString(), CultureInfo.CurrentCulture)

    End Function

    Private Sub New()
    End Sub

  End Class
End Namespace